import { createSlice } from '@reduxjs/toolkit'

const toastSlice = createSlice({
  name: 'user',
  initialState: {
    show: false,
    message: '',
    type: 'success'
  },
  reducers: {
    show(state, { payload }) {
      state.show = true;
      state.message = payload.message;
      state.type = payload.type;
    },
    hide(state) {
      state.show = false;
    }
  }
})

export const { show, hide } = toastSlice.actions;
export default toastSlice.reducer;